package cate.game.pvp.throne;

import cate.game.framework.ModuleMan;
import cate.game.play.part.PlaySide;
import cate.game.pvp.throne.msg.*;
import cate.game.role.Role;
import easy.java.dev.note.NoteClass;

import java.util.List;

@NoteClass("王座争霸-Game发送消息模块")
public class TBGameMessagingModule extends ModuleMan {

    @Override
    public void initDependent() throws Exception {
        serverConnect();
    }

    /**
     * 服务器连接
     */
    public void serverConnect() {
        try {
            game.rpcSend().fireAndForgetGroup(TBInnerMsg.GAME_CONNECT, game.config.srvId);
        }catch (Exception e){
            log.error("出错啦大概是组服没有启动", e);
        }
    }


    /**
     * 获取选拔赛对手
     */
    public TBTrialOpponentInnerResp getTrialOpponent(Role role) {
        return game.rpcSend().requestResponseGroup(TBInnerMsg.TRIAL_OPPONENT_REQ, TBTrialOpponentReq.of(role), TBTrialOpponentInnerResp.class);
    }

    /**
     * 同步积分和阵容
     * @param role
     */
    public void trialSyncRank(Role role, PlaySide playSide){
        game.rpcSend().fireAndForgetGroup(TBInnerMsg.TRIAL_SYNC_RANK_REQ, TBTrialRankSyncReq.of(role,playSide));
    }

    /**
     * 获取选拔赛数据
     * @param group
     * @return
     */
    public TBTrialInnerResp getTrialData(int group) {
        return game.rpcSend().requestResponseGroup(TBInnerMsg.TRIAL_DATA_REQ, TBTrialInnerReq.of(group), TBTrialInnerResp.class);
    }

    /**
     * 同步淘汰赛阵容
     * @param playSide
     */
    public void syncKoPosition(PlaySide playSide){
        game.rpcSend().fireAndForgetGroup(TBInnerMsg.UPDATE_KO_POSITION, TBKoSyncPositionReq.of(playSide));
    }

    /**
     * 查看玩家阵容
     * @param roleUid
     */
    public TBKoPlaySideInnerResp getPlaySide(String roleUid){
        return game.rpcSend().requestResponseGroup(TBInnerMsg.PLAY_SIDE_REQ, TBKoPlaySideInnerReq.of(roleUid),TBKoPlaySideInnerResp.class);
    }

    /**
     * 竞猜
     * @param team
     * @return
     */
    public void koBet(byte team) {
        TBKoBetNotice notice = game.rpcSend().requestResponseGroup(TBInnerMsg.KO_BET_REQ, TBKoBetInnerReq.of(team), TBKoBetNotice.class);
        game.pvp.throne.data.holder.syncKoBet(notice);
    }

    /**
     * 冠军boss挑战检测
     * @param roleUid
     * @return
     */
    public TBBossCheckInnerResp bossCheck(String roleUid, List<String> heroList) {
        return game.rpcSend().requestResponseGroup(TBInnerMsg.BOSS_CHECK, TBBossCheckInnerReq.of(roleUid,heroList), TBBossCheckInnerResp.class);
    }

    /**
     * 冠军boss挑战记录同步
     * @param req
     * @return
     */
    public TBBossResultInnerResp bossReport(TBBossResultInnerReq req) {
        return game.rpcSend().requestResponseGroup(TBInnerMsg.BOSS_RESULT, req, TBBossResultInnerResp.class);
    }


    /**
     * 添加选拔赛排行榜机器人
     */
    public void gmAddTrialRivalRobot(int levelGroup,int num,PlaySide playSide){
        game.rpcSend().fireAndForgetGroup(TBInnerMsg.GM_ADD_RIVAL_ROBOT_REQ, TBGMAddRivalRobotReq.of(levelGroup,num,playSide));
    }


    /**
     * 添加选拔赛排行榜机器人
     */
    public void gmAddTrialRankRobot(int levelGroup,int num,PlaySide playSide){
        game.rpcSend().fireAndForgetGroup(TBInnerMsg.GM_ADD_TRIAL_ROBOT_REQ, TBGMAddTrialRobotReq.of(levelGroup,num,playSide));
    }

}
